//
//  SpecialViewController.m
//  TestDemo
//
//  Created by 张润东 on 2021/8/19.
//

#import "SpecialViewController.h"
#import <CHNMarcos/MacroDefinition.h>
#import "ViewController.h"
@interface SpecialViewController ()

@end

@implementation SpecialViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor cyanColor];
    UIButton *btn = [UIButton new];
    btn.frame =CGRectMake(SafeArea_Height(), NAV_HEIGHT, SmtSize(100), SmtSize(120));
    [btn setTitleColor:Title_Color() forState:UIControlStateNormal];
    [btn setTitleColor:Comment_Color() forState:UIControlStateHighlighted];
    [self.view addSubview:btn];
    [btn.titleLabel setFont:SmtCustomFont(22, UIFontWeightMedium)];
    [btn setTitle:@"你好啊" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(nextView) forControlEvents:UIControlEventTouchUpInside];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;//状态栏颜色 黑白
    [self.navigationController.navigationBar setBackgroundImage:[self imageWithColor:[UIColor systemGreenColor]] forBarMetrics:UIBarMetricsDefault];//背景颜色
}


- (UIImage*)imageWithColor:(UIColor *)color{
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, color.CGColor);
    CGContextFillRect(context, rect);
    UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSData* imageData = UIImageJPEGRepresentation(image, 1.0f);
    image = [UIImage imageWithData:imageData];
    return image;
}

-(void)nextView{
    ViewController*vc =  [[ViewController alloc]init];
    vc.view.backgroundColor=[UIColor whiteColor];
    [self.navigationController pushViewController:vc animated:YES];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
